package com.xma.springcloud.controller;

import com.xma.springcloud.common.ResponseResult;
import com.xma.springcloud.entity.Payment;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

/**
 * @Author: arthur
 * @License: (C) Copyright 2020-2028, xxx Corporation Limited.
 * @Contact: 413911174@qq.com
 * @Date: 2020/7/5 20:56
 * @Version: 1.0
 * @Description:
 */
@RestController
public class PaymentController {

    @Value("${server.port}")
    private String serverPort;

    public static HashMap<Long, Payment> hashMap = new HashMap<>();

    static {
        hashMap.put(1L,new Payment(1L,"1111111111111111111111111"));
        hashMap.put(2L,new Payment(2L,"2222222222222222222222222"));
        hashMap.put(3L,new Payment(3L,"3333333333333333333333333"));
    }

    @GetMapping(value = "/paymentSQL/{id}")
    public ResponseResult<Payment> paymentSQL(@PathVariable("id") Long id){
        Payment payment = hashMap.get(id);
        ResponseResult<Payment> result = new ResponseResult<>(200,"from mysql,serverPort: " + serverPort,payment);
        return result;
    }
}
